use "/Users/jrthornton/Desktop/Replication/anes_timeseries_2016" , clear
set more off

gen year = 2016
* weight
gen w = V160101
******************
* SOPHISTICATION *
******************
* Created with three items: knowledge, interest, and involvement
		
* Knowledge (DONE)
gen interviewer_assesment = V168016
recode interviewer_assesment (-8=.) (-1=.) (1=5) (5=1) (2=4) (4=2)

* Interest (DONE)
gen interest = V161004
recode interest (9=.) (0=.) (1=3) (3=1)

* Involvement 
*Attendance at political events*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Attendm = V162011
recode Attendm (2=0) (-6=.) (-7=.) (-8=.) (-9=.)
label var Attendm "Attend a Political Event"
label define Attendancem 0 "No" 1 "Yes" , replace
label values Attendm Attendancem

*Work for a political candidate*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Workm = V162013
recode Workm (2=0) (-6=.) (-7=.) (-8=.) (-9=.)
label var Workm "Work for a Political Candidate"
label define Workedm 0 "No" 1 "Yes", replace
label values Workm Workedm

*Political expression in the form of a campaign button or sticker*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Displaym = V162012
recode Displaym (2=0) (-6=.) (-7=.) (-8=.) (-9=.)
label var Displaym "Display a Campaign Button or Sticker"
label define Displaypoliticsm 0 "No" 1 "Yes" , replace
label values Displaym Displaypoliticsm

*Donation to a political candidate*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Donatecm = V162014
recode Donatecm (2=0) (-6=.) (-7=.) (-8=.) (-9=.)
label var Donatecm "Donate money to a political candidate"
label define Donatecandidatem 0 "No" 1 "Yes" , replace
label values Donatecm Donatemoneycm

*Donation to a political party*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Donatepm = V162016
recode Donatepm (2=0) (-6=.) (-7=.) (-8=.) (-9=.)
label var Donatepm "Donate money to a political party"
label define Donatepartym 0 "No" 1 "Yes" , replace
label values Donatepm Donatepartym

*Did R talk to anyone about voting for or against cand or pty to a political party*
*Note: This value is recoded so that higher values reflect greater* 
*political involvement*

gen Talk = V162010
recode Talk (2=0) (-6=.) (-7=.) (-8=.) (-9=.)
label var Talk "Talk to to anyone for or against"
label define Talkm 0 "No" 1 "Yes" , replace
label values Talk Talkm



gen involvement=( Attendm+ Workm+ Displaym+ Donatecm+ Donatepm+ Talk)

gen house = V161515
recode house (-9=0) (-5=.) (1=0) (2=1)

*******************
* EQUALITARIANISM *
*******************
* Scale created from six tiems
	* 1. 'Our society should do whatever is necessary to make sure that 
			* everyone has an equal opportunity to succeed.'
	* 2. 'We have gone too far in pushing equal rights in this country.'
	* 3. 'One of the big problems in this country is that we don't give
			* everyone an equal chance.'
	* 4. 'It is not really that big a problem if some people have more of a
			* chance in life than others.'
	* 5. 'The (2004: This_ country would be better off if we worried less
			* about how equal people are.'		
	* 6. 'If people were treated more equally in this country we would have
			* many fewer problems.'

gen equality1 = V162243
recode equality1 (-8=.) (-9=.) (-7=.) (-6=.)
recode equality1 (1=5) (5=1) (2=4) (4=2)

*gen equality2 = VCF9014 (not asked in 2016)
*recode equality2 (8=.) (9=.)

*gen equality3 = VCF9015 (not asked in 2016)
*recode equality3 (8=.) (9=.)
*recode equality3 (1=5) (5=1) (2=4) (4=2)

gen equality4 = V162245
recode equality4 (-8=.) (-9=.) (-7=.) (-6=.)

gen equality5 = V162244
recode equality5 (-8=.) (-9=.) (-7=.) (-6=.)

gen equality6 = V162246
recode equality6 (-8=.) (-9=.) (-7=.) (-6=.)
recode equality6 (1=5) (5=1) (2=4) (4=2)

gen equality = (equality1 + equality4 + equality5 ///
	+ equality6)/4
su equality, meanonly
replace equality = (equality- r(min)) /(r(max) - r(min))


*******************
* GROUP VARIABLES *
*******************
* Race
gen race = V161310x
recode race (-2=.) (3=4) (4=4) (5=3) (6=4)
label define racelabel 1 "White" 2 "Black" 3 "Hispanic" 4 "Other" 
label values race racelabel  
*1. White non-Hispanic
*2. Black non-Hispanic
*3. Hispanic
*4. Other or multiple races, non-Hispanic

* Gender
gen sex = V161342
recode sex (-9=.) (3=.)
replace sex = sex-1
label define sexlabel 0 "Male" 1 "Female" 
label values sex sexlabel



*********************
* CONTROL VARIABLES *
*********************

gen age = V161267
recode age (-9=.) (-8=.)

gen educ = V161270
recode educ (-9=.) (90=9) (95=.)
recode educ ///
	(1=1) (2=1) (3=1) (4=1) ///
	(5=2) (6=2) (7=2) (8=2) ///
	(9=3) ///
	(10=4) (11=4) (12=4) ///
	(13=5) (14=5) (15=5) (16=5)

gen income = V161361x
replace income = . if income<1

* Ideology
gen ideology = V162171
recode ideology (9=.) (0=.)

* Partisanship
gen pid = V161158x
recode pid (-8=.) (-9=.)
# delimit ; 
label define pid_label        
		1 "Strong Democrat" 
        2 "Weak Democrat" 
        3 "Independent - Democrat" 
        4 "Independent - Independent" 
        5 "Independent - Republican" 
		6 "Weak Republican" 
        7 "Strong Republican"
;
# delimit cr
label values pid pid_label

gen pidi = abs(pid-4)
# delimit ; 
label define pidi_label        
		0 "Independent" 
		1 "Weak partisan" 
        2 "Partisan" 
		3 "Strong partisan" 
;
# delimit cr
label values pidi pidi_label

gen democrat = 1 if pid<4


gen party = 0 if pid<4
replace party = 1 if pid==4
replace party = 2 if pid>4
label define partylabel 0 "Democrat" 1 "Independent" 2 "Republican" 
label values party partylabel





***** NATOINALISM
gen english_important = V161197
recode english_important (-9=.)
revrs english_important, replace






gen gay_adopt = V161230	
recode gay_adopt (-9=.) (-8=.)
recode gay_adopt (2=0)


gen gay_discrimination = V161229x	
recode gay_discrimination (-2=.)
revrs gay_disc , replace	



gen gay_marriage = V161231	
recode gay_marriage (-9=.) (-8=.)		(1=3) (3=1)


gen therm_gays = V162103
replace therm_gays = . if therm_gays<0
replace therm_gays = . if therm_gays>110


gen sexual_orientation = V161511
recode sexual_orientation (-9=.) (-5=.) (1=0) (2=1) (3=2)
label define orientation_label 0 "Straight" 1 "Gay" 2 "Bisexual" 
label values sexual_orientation orientation_label
gen gay = sexual_orientation
recode gay (2=1)
label define gay_label 0 "Straight" 1 "Gay or bisexual" 
label values gay gay_label




*est drop _all
*svy: reg gay_issues c.soph_irt##i.gay pidi age income educ i.sex i.race equality_irt if party==0
*margins , at(soph=(0(.2)1) gay=0) post noatlegend
*est sto straight
*svy: reg gay_issues c.soph_irt##i.gay pidi age income educ i.sex i.race equality_irt if party==0
*margins , at(soph=(0(.2)1) gay=1) post noatlegend
*est sto gay

*# delimit ;
*	coefplot 
*	(gay , msymbol(diamond) mcolor(black)) 
*	(straight , msymbol(square) mcolor(black)) 
*	,	at 	
*	lwidth(*1) 
*	ciopts(lcolor(black)) 
*	ylab(, format(%03.1f))
*	xlab(, format(%03.1f))
*	ytitle("Support for laws to protect gays and  lesbians" 
*	"against job discrimination")
*	xtitle(Sophistication) 
*	legend(order(2 "Gay" 4 "Straight") pos(6) col(3)  
*		region(lcolor(none)))
*	aspect(1)
*    ;
*# delimit cr




* Women issues






keep equality1 equality4 equality5 equality6 interviewer_assesment  interest  involvement gay_discrimination gay_marriage gay_adopt gay year  income party race gay pidi age ideo sex educ therm_gays house w
save "/Users/jrthornton/Desktop/Replication/2016_combined.dta" , replace



